//
//  LineNodeCCell.m
//  ImGuider
//
//  Created by 李陆涛 on 2017/12/26.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "LineNodeCCell.h"

@interface LineNodeCCell ()

@property (weak, nonatomic) IBOutlet UIImageView *lineImageView;

@property (weak, nonatomic) IBOutlet UILabel *spotCountLabel;
@property (weak, nonatomic) IBOutlet UIImageView *transportationImageView;
@property (weak, nonatomic) IBOutlet UILabel *countryLabel;
@property (weak, nonatomic) IBOutlet UILabel *lineNameLabel;
@property (weak, nonatomic) IBOutlet UIImageView *guiderImageView;
@property (weak, nonatomic) IBOutlet UIImageView *guiderVipImageView;
@property (weak, nonatomic) IBOutlet UIView *mengbanView;
@property (weak, nonatomic) IBOutlet UIImageView *locationImageView;

@end


@implementation LineNodeCCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.mengbanView.backgroundColor = kMengBanColor;
    self.lineNameLabel.textColor = kTitleColor;
    
    self.guiderImageView.layer.borderWidth = 1.0f;
    self.guiderImageView.layer.borderColor = kBGColor.CGColor;
}

- (void)setType:(NSInteger)type {
    
    _type = type;
    
    if (type == 1) {
        
        [self.guiderImageView removeFromSuperview];
        [self.guiderVipImageView removeFromSuperview];
    }
}

- (void)setModel:(LineModel *)model {
    
    _model = model;
    
    [self.lineImageView setImageURL:[NSURL URLWithString:[model.pictureArray firstObject]] placeholderImage:kPlaceholderRec];
    
    NSString *str1 = model.recordcount;
    NSString *str2 = MYLocalizedString(@"MYDOWNLOAD_TOTAL", nil);
    
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ %@",str1,str2]];
    
    [attrStr addAttribute:NSFontAttributeName value:FontBold(18) range:str1.rangeOfAll];
    [attrStr addAttribute:NSFontAttributeName value:Font(12) range:NSMakeRange(str1.length, str2.length+1)];
    
    self.spotCountLabel.attributedText = attrStr;
    if (!self.isCountry) {
        self.countryLabel.text = model.country;
        self.locationImageView.hidden = NO;
    }else{
        self.countryLabel.text = @"";
        self.locationImageView.hidden = YES;
    }
    
    
    self.lineNameLabel.text = model.linename;
    [self.guiderImageView setImageURL:[NSURL URLWithString:model.guide.headimg] placeholderImage:[UIImage imageNamed:@"default"]];
    self.guiderVipImageView.hidden = !model.guide.vip;
   
    
    switch (model.transport.integerValue) {
        case 1:
            self.transportationImageView.image = [UIImage  imageNamed:@"urbanline_foot_white"];
            break;
        case 2:
            self.transportationImageView.image = [UIImage  imageNamed:@"urbanline_bus_white"];
            break;
        case 3:
            self.transportationImageView.image = [UIImage  imageNamed:@"urbanline_ship_white"];
            break;
        case 4:
            self.transportationImageView.image = [UIImage  imageNamed:@"urbanline_car_white"];
            break;
            
        default:
            self.transportationImageView.image = [UIImage  imageNamed:@"urbanline_foot_white"];
            break;
    }
    
    if (model.type.integerValue != 1) {
        
        self.transportationImageView.hidden = YES;
    }else{
        self.transportationImageView.hidden = NO;
    }
}

@end

